//
//  OCSSSelfRequestListPage.swift
//  OCSSStoreSwift
//
//  Created by MacMiniKangChe on 2018/11/5.
//  Copyright © 2018年 MacMiniKangChe. All rights reserved.
//

import UIKit

class OCSSSelfRequestListPage: OCSSBaseRefreshViewController,UITableViewDelegate, UITableViewDataSource {

    override func viewDidLoad() {
        super.viewDidLoad()

        title = "求购列表";
        self.regTableViewNib(tableView: tableView, className: OCSSSelfRequestListCell.className());
        tableView.rowHeight = 88;
        requestForListData();
    }
    //MARK:网络请求
    func requestForListData() -> Void {
        let params = ["pageIndex":self.page]
        OCSSNetRequest.requestData(url: "/Marketing/WantBuyList", para: params, type: MethodType.post, success: { (result) in
            print(result);
        }) { (error) in
            print(error);
        };
        
    }
    //MARK:刷新
    override func refresh() {
        self.page = 1;
        requestForListData();
    }
    override func loadMore() {
        self.page += 1;
        requestForListData();
    }
    //按钮点击事件
    @IBAction func publishRequestButtonEvent(_ sender: UIButton) {
        let publishPage = OCSSPublishRequestPage.init();
        navigationController?.pushViewController(publishPage, animated: true);
        
    }
    //MARK:UITableViewDelegate && UITableViewDataSource
    func numberOfSections(in tableView: UITableView) -> Int {
        return 5;
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1;
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "OCSSSelfRequestListCell") as! OCSSSelfRequestListCell;
        cell.selectionStyle = UITableViewCellSelectionStyle.none;
        
        return cell;
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.01;
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 14;
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
